package org.md.budzik.problems;

import java.math.BigInteger;

/**
 * Obsługa silni.
 * @author Wiezzel
 *
 */
public class Factorial extends OneArgOp {

	public static BigInteger fact(BigInteger value) {
		if (value.compareTo(BigInteger.ONE) <= 0)
			return BigInteger.ONE;
		else return value.multiply(fact(value.subtract(BigInteger.ONE)));	
	}
	
	public Factorial(Expression ex) {
		super(ex);
	}
	
	protected BigInteger computeOperation(BigInteger value) {
		return fact(value);
	}

	protected String operationSymbol() {
		return "!";
	}

}
